/*
 * Copyright (c) 2019 DawnFramework. All Rights Reserved.
 * Licensed under the MIT (LICENSE) license.
 */

package org.dawn.common.apiclient.json;

import com.alibaba.fastjson.JSON;

import java.lang.reflect.Type;
import java.util.List;

/**
 * @author Willard Hu on 2019-04-28.
 */
public class FastJsonImpl implements Json {

    @Override
    public String serialize(Object obj) {
        return JSON.toJSONString(obj);
    }

    @Override
    public <T> T deserialize(String body, Type dataType) {
        return JSON.parseObject(body, dataType);
    }

    @Override
    public <T> List<T> deserializeArray(String body, Class<T> clz) {
        return JSON.parseArray(body, clz);
    }


}
